ValidationResult

A result of any type T that is wrapped with an optional error message

Used to provide contextual error information "upstream" of where the error was encountered, which allows for better logging where upstream elements can collate error messages passed back to them into an organized and sensible error log.

This class has a private constructor to force the use of the pre-defined static instantiation methods

Author

fzzyhmstrs

Since

0.1.0

Parameters

T

result type, can be nullable

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard

Adds another test, and potentially another error, to a Validation.

Link copied to clipboard
fun get(): T

Gets the wrapped result value

Link copied to clipboard

Supplies the error message stored within

Link copied to clipboard

Boolean check to determine if this result is holding an error

Link copied to clipboard

Boolean check to determine if this result is valid (no errors)

Link copied to clipboard
Link copied to clipboard

reports error, if any, to a provided reporter (such as a logger)

reports error, if any, to a provided string list

Link copied to clipboard

Creates a new ValidationResult of type T wrapping the new value with the error(if any) from the receiver ValdiationResult (of any type, does not need to match T)

Link copied to clipboard
fun writeError(errors: List<String>)

Writes an error log to console if this validation result is errored

Link copied to clipboard
fun writeWarning(errors: List<String>)

Writes a warning log to console if this validation result is errored